<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <title>后台登录</title>
</head>
<body>

<form id="form">
用户名<input type="text" name="name" /><br /><br />

密码：<input type="password" name="pwd" /><br /><br />
<br /><br />
验证码：<input type="text" name="code" /><img src="{:U('login/verify')}" alt="captcha" onclick="this.src='{:U('login/verify')}?t='+new Date().getTime()" />

<br /><br />
</form>
<button onclick="submit()">登录</button>

<script src="/js/jquery-1.8.2.min.js"></script>
<script src="/js/layer/layer-min.js"></script>
<script>
    function submit(){
        var formdata=new FormData($("#form")[0]);
        $.ajax({
            type:"post",
            url:"{:U('login/login')}",
            data:formdata,
            dataType:"json",
            processData:false,
            contentType:false,
            cache:false,
            success:function(rs){
                layer.msg(rs.msg);
                if(rs.res==1 && rs.data.url !=undefined){
                    window.location=rs.data.url;
                }

            }
        });
    }

</script>
</body>
</html>